using System.Collections.Generic;

namespace OffsetPath
{
    public class ClassAq : List<PuntoDueD>
    {
        public void a()
        {
            ClassU comparer = new ClassU();
            base.Sort(comparer);
        }

        public void a(List<int> A_0)
        {
            if (A_0.Count == base.Count)
            {
                this.a(A_0, 0, base.Count - 1);
            }
        }

        public void a(ClassAq A_0)
        {
            for (int i = 0; i < A_0.Count; i++)
            {
                base.Add(A_0[i]);
            }
            A_0.Clear();
        }

        public void a(ClassAb A_0)
        {
            if (base.Count == 0)
            {
                A_0.j();
            }
            else
            {
                A_0.MethodB(base[0]);
                for (int i = 1; i < base.Count; i++)
                {
                    A_0.e(base[i]);
                }
            }
        }

        public void a(List<PuntoDueD> A_0)
        {
            base.Clear();
            for (int i = 0; i < A_0.Count; i++)
            {
                base.Add(new PuntoDueD(A_0[i]));
            }
        }

        public void a(ForseLineaClassA classA0)
        {
            ClassR comparer = new ClassR {
                                   classA = classA0
                               };
            base.Sort(comparer);
        }

        public void a(ClassG A_0)
        {
            if (base.Count < 3)
            {
                if (base.Count == 2)
                {
                    A_0.MethodA(base[0], base[1]);
                }
                else if (base.Count == 1)
                {
                    A_0.MethodB(base[0], (double) 0.0);
                }
            }
            else
            {
                int num = 0;
                int num2 = 0;
                int num3 = 0;
                double num4 = 0.0;
                this.a(ref num, ref num2, ref num4);
                A_0.MethodA(base[num], base[num2]);
                bool flag = false;
                for (int i = 0; i < base.Count; i++)
                {
                    if (((i != num) && (i != num2)) && !A_0.MethodA(base[i]))
                    {
                        num3 = i;
                        A_0.MethodB(base[num], base[num2], base[num3]);
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    for (int j = 0; j < base.Count; j++)
                    {
                        if (((j != num) && (j != num2)) && ((j != num3) && !A_0.MethodA(base[j])))
                        {
                            double num7 = base[j].MethodC(base[num]);
                            double num8 = base[j].MethodC(base[num2]);
                            double num9 = base[j].MethodC(base[num3]);
                            if ((num7 < num8) && (num7 < num9))
                            {
                                num = j;
                            }
                            else if (num8 < num9)
                            {
                                num2 = j;
                            }
                            else
                            {
                                num3 = j;
                            }
                            A_0.MethodB(base[num], base[num2], base[num3]);
                        }
                    }
                }
            }
        }

        public PuntoDueD a(int A_0)
        {
            PuntoDueD puntoDueD = base[A_0];
            base.RemoveAt(A_0);
            return puntoDueD;
        }

        public void a(PuntoDueD A_0)
        {
            base.Add(new PuntoDueD(A_0));
        }

        private int a(int A_0, ref double A_1)
        {
            int num;
            if ((base.Count < 2) || (A_0 >= base.Count))
            {
                return 0;
            }
            if (A_0 == 0)
            {
                A_1 = base[1].MethodC(base[A_0]);
                num = 1;
            }
            else
            {
                A_1 = base[0].MethodC(base[A_0]);
                num = 0;
            }
            for (int i = 1; i < base.Count; i++)
            {
                if (i != A_0)
                {
                    double num3 = base[i].MethodC(base[A_0]);
                    if (num3 > A_1)
                    {
                        A_1 = num3;
                        num = i;
                    }
                }
            }
            return num;
        }

        private void a(List<int> A_0, int A_1, int A_2)
        {
            int num = A_1;
            int num2 = A_2;
            if (num < num2)
            {
                if (num == (num2 - 1))
                {
                    if (A_0[num] > A_0[num2])
                    {
                        int num3 = A_0[num];
                        A_0[num] = A_0[num2];
                        A_0[num2] = num3;
                        PuntoDueD puntoDueD = base[num];
                        base[num] = base[num2];
                        base[num2] = puntoDueD;
                    }
                }
                else
                {
                    int num4 = A_0[(num + num2) / 2];
                    A_0[(num + num2) / 2] = A_0[num2];
                    A_0[num2] = num4;
                    PuntoDueD x2 = base[(num + num2) / 2];
                    base[(num + num2) / 2] = base[num2];
                    base[num2] = x2;
                    while (num < num2)
                    {
                        while ((A_0[num] <= num4) && (num < num2))
                        {
                            num++;
                        }
                        while ((num4 <= A_0[num2]) && (num < num2))
                        {
                            num2--;
                        }
                        if (num < num2)
                        {
                            int num5 = A_0[num];
                            A_0[num] = A_0[num2];
                            A_0[num2] = num5;
                            PuntoDueD x3 = base[num];
                            base[num] = base[num2];
                            base[num2] = x3;
                        }
                    }
                    A_0[A_2] = A_0[num2];
                    A_0[num2] = num4;
                    base[A_2] = base[num2];
                    base[num2] = x2;
                    this.a(A_0, A_1, num - 1);
                    this.a(A_0, num2 + 1, A_2);
                }
            }
        }

        public void a(ref int A_0, ref int A_1, ref double A_2)
        {
            this.a(ref A_0, ref A_1, ref A_2, 0);
            ClassAtPuntoIncrementale classAt = new ClassAtPuntoIncrementale(base[A_0], base[A_1]);
            classAt.d((double) 0.5);
            ClassG classG = new ClassG(PuntoDueD.MethodB(base[A_0], new PuntoDueD(classAt)), A_2 / 2.0);
            for (int i = 0; i < base.Count; i++)
            {
                if (((i != A_0) && (i != A_1)) && !classG.MethodA(base[i]))
                {
                    double num2 = 0.0;
                    int num3 = this.a(i, ref num2);
                    if (num2 > A_2)
                    {
                        A_0 = i;
                        A_1 = num3;
                        A_2 = num2;
                    }
                }
            }
        }

        public void a(ref int A_0, ref int A_1, ref double A_2, int A_3)
        {
            if (base.Count < 3)
            {
                if (base.Count == 2)
                {
                    A_0 = 0;
                    A_1 = 1;
                    return;
                }
                if (base.Count == 1)
                {
                    A_0 = 0;
                    A_1 = 0;
                    return;
                }
                A_0 = 0;
                A_1 = 0;
                return;
            }
            A_0 = A_3;
            A_1 = this.a(A_0, ref A_2);
            int num = -1;
            while (true)
            {
                num = this.a(A_1, ref A_2);
                if (num == A_0)
                {
                    return;
                }
                A_0 = A_1;
                A_1 = num;
            }
        }

        public void b()
        {
            if (base.Count >= 2)
            {
                for (int i = 0; i < base.Count; i++)
                {
                    int index = i + 1;
                    while (index < base.Count)
                    {
                        if (base[i].MethodB(base[index]))
                        {
                            base.RemoveAt(index);
                        }
                        else
                        {
                            index++;
                        }
                    }
                }
            }
        }

        public void b(ForseLineaClassA classA0)
        {
            ClassP comparer = new ClassP {
                                   classA = classA0
                               };
            base.Sort(comparer);
        }

        public void b(List<PuntoDueD> A_0)
        {
            for (int i = 0; i < A_0.Count; i++)
            {
                base.Add(new PuntoDueD(A_0[i]));
            }
        }

        public void b(ClassAq A_0)
        {
            base.Clear();
            if (A_0.Count < 4)
            {
                this.a(A_0);
            }
            else
            {
                PuntoDueD puntoDueD = A_0[0];
                int num = 0;
                for (int i = 1; i < A_0.Count; i++)
                {
                    PuntoDueD x2 = A_0[i];
                    if (x2.X < puntoDueD.X)
                    {
                        puntoDueD = x2;
                        num = i;
                    }
                }
                base.Add(A_0.a(num));
                A_0.b(base[0]);
                base.Add(A_0.a(0));
                int num3 = 0;
                ClassAq classAq = new ClassAq();
                while (num3 < A_0.Count)
                {
                    int num4 = base.Count - 1;
                    ForseLineaClassA classA = new ForseLineaClassA(base[num4 - 1], base[num4]);
                    ClassAtPuntoIncrementale classAt = new ClassAtPuntoIncrementale(base[num4], A_0[num3]);
                    if (classAt.f() < classA.b.f())
                    {
                        classAq.Add(this.a(num4));
                    }
                    else
                    {
                        base.Add(A_0.a(num3));
                    }
                }
                A_0.a(classAq);
            }
        }

        public void b(PuntoDueD A_0)
        {
            ClassJ comparer = new ClassJ {
                                   a = A_0
                               };
            base.Sort(comparer);
        }

        public void c(PuntoDueD A_0)
        {
            ClassE comparer = new ClassE {
                                   a = A_0
                               };
            base.Sort(comparer);
        }

        ~ClassAq()
        {
        }
    }
}

